package rpt

import (
	"gitee.com/alex_li/amazon-rpt/internal/db"
	"gitee.com/alex_li/amazon-rpt/internal/sdk/advertising"
	"gitee.com/alex_li/amazon-rpt/internal/sdk/dict"
	"gitee.com/alex_li/amazon-rpt/internal/tool"
	"time"
)

type Template struct {
	Name     string
	Product  dict.AdProductType
	Group    []string
	Columns  []db.Column
	RptType  dict.ReportTypeId
	TimeUnit dict.RptTimeUnit
	Filters  []advertising.RptFilter
}

func (r *Template) GetTplName() (name string) {
	return r.Name
}

func (r *Template) GetFieldsName() (list []string) {
	for _, c := range r.Columns {
		list = append(list, c.Field)
	}
	return
}

func (r *Template) GetColumnsName() (list []string) {
	for _, c := range r.Columns {
		list = append(list, c.ColumnName)
	}
	return
}

func GenRptName() string {
	return tool.GenMd5Code([]byte(time.Now().String()))
}
